home *** CD-ROM | disk | FTP | other *** search
- class clock.Clock
- {
- var dat;
- var isRun;
- var cttMc;
- var intervalId;
- static var duration = 1000;
- static var modulo = 60;
- static var hourMax = 10;
- static var minuteMax = 0;
- static var secondMax = 0;
- function Clock()
- {
- this.dat = new Array();
- this.dat = [0,0,0];
- this.isRun = false;
- }
- function setCtt(p_cttMc)
- {
- this.cttMc = p_cttMc;
- }
- function executeCallback()
- {
- this.dat[2] = this.dat[2] + 1;
- if(this.dat[2] == clock.Clock.modulo)
- {
- this.dat[2] = 0;
- this.dat[1] = this.dat[1] + 1;
- if(this.dat[1] == clock.Clock.modulo)
- {
- this.dat[1] = 0;
- this.dat[0] = this.dat[0] + 1;
- }
- }
- if(this.dat[0] >= clock.Clock.hourMax)
- {
- if(this.dat[1] >= clock.Clock.minuteMax)
- {
- if(this.dat[2] >= clock.Clock.secondMax)
- {
- this.stopClock();
- _global.ctn.timeOut();
- }
- }
- }
- this.cttMc.refreshTime(this.dat);
- }
- function reStartClock()
- {
- this.stopClock();
- var _loc2_ = 0;
- while(_loc2_ < this.dat.length)
- {
- this.dat[_loc2_] = 0;
- _loc2_ = _loc2_ + 1;
- }
- this.startClock();
- }
- function startClock()
- {
- if(this.isRun == false)
- {
- this.isRun = true;
- this.cttMc.refreshTime(this.dat);
- this.intervalId = setInterval(this,"executeCallback",clock.Clock.duration);
- return undefined;
- }
- return undefined;
- }
- function stopClock()
- {
- this.isRun = false;
- clearInterval(this.intervalId);
- return undefined;
- }
- function getTime()
- {
- return this.dat.concat();
- }
- function setTime(pAry)
- {
- this.dat = pAry.concat();
- this.cttMc.refreshTime(this.dat);
- }
- }
-